// ++++++++++++++++++++++++++++++++++++++++
// 《零基础Go语言算法实战》源码
// ++++++++++++++++++++++++++++++++++++++++
// Author:廖显东（ShirDon）
// Blog:https://www.shirdon.com/
// Gitee:https://gitee.com/shirdonl/goAlgorithms.git
// Buy link :https://item.jd.com/14101229.html
// ++++++++++++++++++++++++++++++++++++++++

package main

import (
	"fmt"
	"reflect"
)

type Json struct {
	tag string `json:"Tag"`
}

func printTag(input interface{}) {
	t := reflect.TypeOf(input).Elem()
	for i := 0; i < t.NumField(); i++ {
		fmt.Printf("结构体字段 %v 对应的json tag是 %v\n", t.Field(i).Name, t.Field(i).Tag.Get("json"))
	}
}

func main() {
	j := Json{
		tag: "test",
	}
	printTag(&j)
}

//$ go run interview1-42.go
//结构体字段 tag 对应的json tag是 Tag
